<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>商品竞拍界面</title>
    <link rel="stylesheet" th:href="@{/common/layui/css/layui.css}">
    <script th:src="@{/common/js/jquery.min.js}" type="text/javascript"></script>
    <script th:src="@{/common/js/base.js}" type="text/javascript"></script>
    <!--<script th:src="@{/common/layui/layui.js}" type="text/javascript"></script>-->
    <!--<script th:src="@{/common/layui/layui.all.js}" type="text/javascript"></script>-->
    <style>
    </style>
</head>
<body>
    <div style="width:80%; height:100px; margin-left: 50px;"  >
        <div class="layui-row"  id="userInfo" style="height: 100px;margin-top: 30px;">
            <div class="layui-row">
                <div class="layui-col-md4">
                    <div class="layui-form-item">
                        <label class="layui-form-label">商品名称:</label>
                        <div class="layui-input-block">
                            <input class="layui-input"  type="text" id="sname" name="sname" lay-verity="required" readonly="readonly"
                                   autocomplete="off" />
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">起拍价格:</label>
                        <div class="layui-input-block">
                            <input class="layui-input"  type="text" id="qpj" name="qpj" lay-verity="required" readonly="readonly"
                                   autocomplete="off" />
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">竞拍价格:</label>
                        <div class="layui-input-block">
                            <input class="layui-input" type="number" id="price" name="price" lay-verity="required"
                                 onchange="checkPrice()"   autocomplete="off" />
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-row" id="btn" style="height: 30px; text-align: center;margin: 0px auto;">
            <input type="button" value="提交" style="margin-top: 20px ;height: 30px;width: 100px ;background-color: #f7514d" onclick="saveAuctiom()" />
        </div>
    </div>
</body>
<script src="../../common/layui/layui.js">


</script>
<script>
    // layui.use('carousel', function(){
    //     var carousel = layui.carousel;
    //     //建造实例
    //     carousel.render({
    //         elem: '#test1'
    //         ,width: '100%' //设置容器宽度
    //         ,arrow: 'always' //始终显示箭头
    //         // ,anim: 'updown' //切换动画方式
    //     });
    // });
</script>
<script type="text/javascript">
    var static_sid = "";
    var static_price = "";
    $(function () {
        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
        parent.layer.title('竞拍界面', index);  //再改变当前层的标题

    });

    function child(id,price,sname) {
        static_sid=id;
        static_price=price;
        $("#sname").val(sname);
        $("#qpj").val(price);
    }
    function checkPrice() {
        var price = $("#price").val();
        if( price == "" || price == undefined ){
            alert("竞拍价格不能为空！！！");
            return;
        }
        if(parseInt(static_price) >= parseInt(price)){
            alert("竞拍价格不能小于等于上一个竞拍价格或起拍价格！！！");
            return;
        }
    }

    function saveAuctiom(){
        var price = $("#price").val();
        if( price == "" || price == undefined ){
            alert("竞拍价格不能为空！！！");
            return;
        }
        if(parseInt(static_price) >= parseInt(price)){
            alert("竞拍价格不能小于等于上一个竞拍价格或起拍价格！！！");
            return;
        }

        var param = {};
        param['price'] =price;
        param['sid'] = static_sid;
        $.ajax({
            type: "POST",
            contentType: "application/x-www-form-urlencoded; charset=utf-8", // post提交乱码
            url: "/goods/saveAuction.do",
            async: true,
            data: param,
            success: function (data) {
                if(data.success){
                    alert("竞拍成功！！！");
                    parent.closeWindow();
                }else{
                    alert(data.msg);
                }
            },
            error: function () {
                alert("程序错误，请重试！！！");
            }
        });
    }

</script>
</html>